#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <mpi.h>

/* DEFINITIONS */

/* Problem Definitions */
#define NUMBER_OF_SERVERS 16
#define NUMBER_OF_CONTENTS 24
#define NUMBER_OF_PERIODS 80


typedef struct {
  int line;
  int column;
} matrix_position;

typedef struct server_node {
  int server;
  struct server_node *next;
} server_node;

typedef struct {
  server_node *head;
  int size;
} server_list;


int insert_server(server_list *list, int server);

int delete_server(server_list *list, int server);

int is_content_present(server_list list, int server);

int get_closest_server(server_list list, int distances[NUMBER_OF_SERVERS], int server);

void init_server_distance(int (*matrix)[NUMBER_OF_SERVERS]);

void init_origin_server(server_list contents[NUMBER_OF_CONTENTS]);

void init_closest_replica(int replicas[NUMBER_OF_CONTENTS], server_list contents[NUMBER_OF_CONTENTS]);

matrix_position get_max_load(int matrix[NUMBER_OF_SERVERS][NUMBER_OF_CONTENTS]);
